package com.aynu.gulimall.product.feign;

import com.aynu.common.to.SkuReductionTo;
import com.aynu.common.to.SpuBoundTo;
import com.aynu.common.utils.R;
import feign.Body;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author mj
 * @version 1.0
 * @date 2020/7/1 15:36
 */
@FeignClient("gulimall-coupon")
public interface CouponFeignService {

    /**
     * 1、CouponFeignService.saveSpuBound
     *   1）、@RequestBody将对象转换为json
     *   2）、找到gulimall-coupon服务，给/coupon/coupon/save发送请求
     *      将上一步转的json放在请求体位置，发送请求
     *   3）、对方服务收到请求。请求体中有json
     *      （@RequestBody SpuBoundsEntity spuBounds）；将请求体的json转换为SpuBoundsEntity
     *只要json数据模型是兼容的，双方无需使用同一个to
     * @param spuBoundTo
     * @return
     * TODO SpuBoundTo和SpuBoundsEntity的id字段不相同
     */
    @PostMapping("/coupon/spubounds/save")
    R saveSpuBound(@RequestBody SpuBoundTo spuBoundTo);


    @PostMapping("coupon/skufullreduction/skuinfo")
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);

}
